{extend name='common@layout/seller' /}
{block name="left"}{include file='common/order_left'}{/block}
{block name="breadcrumb"}
<div class="ncsc-path"><i class="icon-desktop"></i>商家管理中心<i class="icon-angle-right"></i>订单物流<i class="icon-angle-right"></i>发货</div>
{/block}
{block name='content'}
<div class="tabmenu">
   {include file='common/submenu'}
  <a class="ncsc-btn ncsc-btn-green" href="/?s=seller/transport/add&type={:input('type')}">新增运费模板 </a> 
</div>
<?php if (is_array($list)){?>
<table class="ncsc-default-table order">
  <thead>
    <tr>
      <th class="w120">运送方式</th>
      <th class="cell-area tl">运送到</th>
      <th class="w100">首件(个)</th>
      <th class="w100">运费(元)</th>
      <th class="w100">续件(个)</th>
      <th class="w100">运费(元)</th>
    </tr>
  </thead>
  <?php foreach ($list as $v){?>
  <tbody>
    <tr>
      <td colspan="20" class="sep-row"></td>
    </tr>
    <tr>
      <th colspan="20"><?php if ($_GET['type'] == "select"){?>
        <a class="ml5 ncsc-btn-mini ncsc-btn-orange" data-param="{name:'<?php echo $v['title'];?>',id:'<?php echo $v['id'];?>',price:'<?php echo intval($extend[$v['id']]['price']);?>'}" href="javascript:void(0)"><i class="icon-truck"></i>应用模板</span></a>
        <?php }?><h3><?php echo $v['title'];?></h3>
        
        <span class="fr mr5">
        <time title="最后编辑时间"><i class="icon-time"></i><?php echo date('Y-m-d H:i:s',$v['update_time']);?></time>
        <a class="J_Clone ncsc-btn-mini" href="javascript:void(0)" data-id="<?php echo $v['id'];?>"><i class="icon-copy"></i>复制模板</a> <a class="J_Modify ncsc-btn-mini" href="javascript:void(0)" data-id="<?php echo $v['id'];?>"><i class="icon-edit"></i>修改</a> <a class="J_Delete ncsc-btn-mini" href="javascript:void(0)" data-id="<?php echo $v['id'];?>"><i class="icon-trash"></i>删除</a></span></th>
    </tr>
    <?php if (is_array($extend[$v['id']]['data'])){?>
    <?php foreach ($extend[$v['id']]['data'] as $value){?>
    <tr>
      <td class="bdl"><?php echo str_replace(array('kd','py','es'),array('快递','平邮','EMS'),$value['type']);?></td>
      <td class="cell-area tl"><?php echo $value['area_name'];?></td>
      <td><?php echo $value['snum'];?></td>
      <td><?php echo $value['sprice'];?></td>
      <td><?php echo $value['xnum'];?></td>
      <td class="bdr"><?php echo $value['xprice'];?></td>
    </tr>
    <?php }?>
    <?php }?>
  </tbody>
  <?php }?>
</table>
<?php } else {?>
<div class="warning-option"><i class="icon-warning-sign"></i><span>暂无符合条件的数据记录</span></div>
<?php } ?>
<?php if (is_array($list)){?>
<div class="pagination">{$show_page}</div>
<?php }?>

<script>
$(function(){	
	$('a[class="J_Delete ncsc-btn-mini"]').click(function(){
		var id = $(this).attr('data-id');
		if(typeof(id) == 'undefined') return false;
		get_confirm('确认删除此模板？','/?s=seller/transport/delete&type=<?php echo input('type');?>&id='+id);
	});

	$('a[class="J_Modify ncsc-btn-mini"]').click(function(){
		var id = $(this).attr('data-id');
		if(typeof(id) == 'undefined') return false;
		$(this).attr('href','/?s=seller/transport/edit&type=<?php echo input('type');?>&id='+id);
		return true;
	});
	
	$('a[class="J_Clone ncsc-btn-mini"]').click(function(){
		var id = $(this).attr('data-id');
		if(typeof(id) == 'undefined') return false;
		$(this).attr('href','/?s=seller/transport/copy&type=<?php echo input('type');?>&id='+id);
		return true;
	});
	$('a[class="ml5 ncsc-btn-mini ncsc-btn-orange"]').click(function(){
		var data_str = '';
		eval('data_str = ' + $(this).attr('data-param'));
		$("#postageName", opener.document).css('display','inline-block').html(data_str.name);
		$("#transport_title", opener.document).val(data_str.name);
		$("#transport_id", opener.document).val(data_str.id);
		$("#g_freight", opener.document).val(data_str.price);
		window.close();
	});	

});
</script>
{/block}